import process from 'process'

export class IParams {
    pipelineID!: number

    pipelineName!: string

    buildNumber?: number

    workSpace!: string

    projectDir!: string

    buildJobID!: number

    debug!: boolean

    useReplace!: boolean

    skipUndefineVariable!: boolean

    enableAppstackReleaseOrder!: boolean

    systemStepsStandaloneMode!: boolean

    kubectlVersion!: string

    insecureSkipTlsVerify!: boolean

    pathToYaml!: string

    clusterType?: string

    progressDeadlineSeconds!: number

    namespace!: string

    images!: string
}

export function getParams(): IParams {
    let params = new IParams()
    params.pipelineID = Number(process.env.PIPELINE_ID)
    params.pipelineName = process.env.PIPELINE_NAME as string
    params.buildNumber = Number(process.env.BUILD_NUMBER)
    params.workSpace = process.env.WORK_SPACE as string
    params.projectDir = process.env.PROJECT_DIR as string
    params.buildJobID = Number(process.env.BUILD_JOB_ID)
    params.debug = process.env.DEBUG === 'true'
    params.useReplace = process.env.USE_REPLACE === 'true'
    params.skipUndefineVariable = process.env.SKIP_UNDEFINE_VARIABLE === 'true'
    params.enableAppstackReleaseOrder = process.env.ENABLE_APPSTACK_RELEASE_ORDER === 'true'
    params.systemStepsStandaloneMode = process.env.SYSTEM_STEPS_STANDALONE_MODE === 'true'
    params.kubectlVersion = process.env.KUBECTL_VERSION ? process.env.KUBECTL_VERSION : 'v1.11.0'
    params.insecureSkipTlsVerify = process.env.INSECURE_SKIP_TLS_VERIFY === 'true'
    params.pathToYaml = process.env.PATH_TO_YAML ? process.env.PATH_TO_YAML : 'manifests'
    params.namespace = process.env.NAMESPACE ? process.env.NAMESPACE : ''
    params.progressDeadlineSeconds = process.env.PROGRESS_DEADLINE_SECONDS ? Number(process.env.PROGRESS_DEADLINE_SECONDS) : 600
    params.images = process.env.IMAGES as string
    return params
}